package com.asen.commons.core.jdbc.param;

import com.asen.commons.core.jdbc.handler.TypeHandler;

import java.io.Serializable;

/**
 * 参数对象
 *
 * @author Gary
 * @version 1.0
 * @date 2018-11-29
 */
public class ParamObject implements Serializable {

    private static final long serialVersionUID = -6807756042935187650L;

    private Class<?> javaType;

    private Object value;

    private TypeHandler handler;

    public ParamObject(Class<?> javaType) {
        this.javaType = javaType;
    }

    public ParamObject(Class<?> javaType, Object value) {
        this.javaType = javaType;
        this.value = value;
    }

    public ParamObject(Class<?> javaType, Object value, TypeHandler handler) {
        this.javaType = javaType;
        this.value = value;
        this.handler = handler;
    }

    public Class<?> getJavaType() {
        return javaType;
    }

    public void setJavaType(Class<?> javaType) {
        this.javaType = javaType;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public TypeHandler getHandler() {
        return handler;
    }

    public void setHandler(TypeHandler handler) {
        this.handler = handler;
    }

    @Override
    public String toString() {
        return "ParamObject{" + value +
                " (" + javaType.getSimpleName() +
                ", " + handler.getClass().getSimpleName() +
                ")}";
    }
}
